package com.ruoyi.web.controller.system;

import com.ruoyi.web.service.C2IntegrationSmokeFailedDistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/C2IntegrationSmokeFailedDist")
public class C2IntegrationSmokeFailedDistController {

    @Autowired
    private C2IntegrationSmokeFailedDistService integrationTestFailStatsService;

    @GetMapping("/byAll")
    public ResponseEntity<Map<String, Integer>> getResponsiblePartyStatistics() {
        // 调用 Service 层逻辑获取统计数据
        Map<String, Integer> statistics = integrationTestFailStatsService.getResponsiblePartyStatistics();

        // 返回统计数据
        return ResponseEntity.ok(statistics);
    }

    /**
     * 获取当前周负责方的失败次数统计
     * @return Map<String, Integer> 返回负责方及其失败次数
     */
    @GetMapping("/byWeek")
    public ResponseEntity<Map<String, Integer>> getWeeklyResponsiblePartyStatistics() {
        // 调用 Service 层方法获取当前周统计数据
        Map<String, Integer> statistics = integrationTestFailStatsService.getWeeklyResponsiblePartyStatistics();

        // 返回统计数据
        return ResponseEntity.ok(statistics);
    }

    /**
     * 获取当前月负责方的失败次数统计
     * @return Map<String, Integer> 返回负责方及其失败次数
     */
    @GetMapping("/byMonth")
    public ResponseEntity<Map<String, Integer>> getMonthlyResponsiblePartyStatistics() {
        // 调用 Service 层方法获取当前月统计数据
        Map<String, Integer> statistics = integrationTestFailStatsService.getMonthlyResponsiblePartyStatistics();

        // 返回统计数据
        return ResponseEntity.ok(statistics);
    }

    /**
     * 获取当前季度负责方的失败次数统计
     * @return Map<String, Integer> 返回负责方及其失败次数
     */
    @GetMapping("/byQuarter")
    public ResponseEntity<Map<String, Integer>> getQuarterlyResponsiblePartyStatistics() {
        // 调用 Service 层方法获取当前季度统计数据
        Map<String, Integer> statistics = integrationTestFailStatsService.getQuarterlyResponsiblePartyStatistics();

        // 返回统计数据
        return ResponseEntity.ok(statistics);
    }

    /**
     * 获取当前年度负责方的失败次数统计
     * @return Map<String, Integer> 返回负责方及其失败次数
     */
    @GetMapping("/byYear")
    public ResponseEntity<Map<String, Integer>> getYearlyResponsiblePartyStatistics() {
        // 调用 Service 层方法获取当前年度统计数据
        Map<String, Integer> statistics = integrationTestFailStatsService.getYearlyResponsiblePartyStatistics();

        // 返回统计数据
        return ResponseEntity.ok(statistics);
    }
}
